package com.jingming.consult.activity

import android.app.Activity
import android.content.Context
import android.content.Intent
import android.os.Bundle
import com.bumptech.glide.Glide
import com.jingming.consult.R
import com.jingming.consult.base.BaseActivity
import com.jingming.consult.videoplayer.TxVideoPlayerController
import kotlinx.android.synthetic.main.activity_videodes.*

/**
 * 视频详情
 */
class VideoDesActivity : BaseActivity(), TxVideoPlayerController.ControllerCallBack {
    companion object {
        /**
         *
         */
        fun startVideoDesActivity(context: Context) {
            var intent = Intent(context, VideoDesActivity::class.java);
            if (!(context is Activity)) {
                intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
            }
            context.startActivity(intent)

        }
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_videodes)
        initData()
    }

    private fun initData() {
        videoPlayer.setControllerCallBack(this@VideoDesActivity)
        Glide.with(this)
            .load("http://jzvd-pic.nathen.cn/jzvd-pic/e7ea659f-c3d2-4979-9ea5-f993b05e5930.png")
            .into(videoPlayer.imageView())
        videoPlayer.setUp("http://jzvd.nathen.cn/c6e3dc12a1154626b3476d9bf3bd7266/6b56c5f0dc31428083757a45764763b0-5287d2089db37e62345123a1be272f8b.mp4")
    }

    override fun payGetUrl() {

    }

    override fun share() {

    }

    override fun finishActivity() {
        finish()
    }

    override fun onDestroy() {
        super.onDestroy()
        videoPlayer.release()
    }

    override fun onResume() {
        super.onResume()
        videoPlayer.restart()
    }

    override fun onPause() {
        super.onPause()
        videoPlayer.pause()
    }
}